Add a test for #432
authorAlex Crichton <alex@alexcrichton.com>
Wed, 24 Sep 2014 05:14:02 +0000 (22:14 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Fri, 3 Oct 2014 01:43:26 +0000 (18:43 -0700)
All problems have been fixed in the previous commits, and this now closes #432

src/cargo/ops/cargo_rustc/mod.rs
tests/test_cargo_compile_path_deps.rs
tests/test_cargo_cross_compile.rs
tests/test_cargo_test.rs

index 6a5067376d9d8331d2a1c6114d2a78aed2578aab..4260ab34f0615a26b374d806f4de7ac0c3a64cc3 100644 (file)
@@ -11,8 +11,6 @@ use util::{Config, internal, ChainError, Fresh, profile};
 use self::job::{Job, Work};
 use self::job_queue as jq;
 use self::job_queue::JobQueue;
-use self::context::{Context, PlatformRequirement, PlatformTarget};
-use self::context::{PlatformPlugin, PlatformPluginAndTarget};
 
 pub use self::compilation::Compilation;
 pub use self::context::Context;
index 583289cc6a67eeaf636bc3c37b229bbaadba952e..2723455750e45b3ab107b9c9a6d3b5f458221fb4 100644 (file)
@@ -712,7 +712,10 @@ test!(dev_deps_no_rebuild_lib {
                 name = "foo"
                 doctest = false
         "#)
-        .file("src/lib.rs", "")
+        .file("src/lib.rs", r#"
+            #[cfg(test)] extern crate bar;
+            #[cfg(not(test))] fn foo() { env!("FOO"); }
+        "#)
         .file("bar/Cargo.toml", r#"
             [package]
 
@@ -722,20 +725,11 @@ test!(dev_deps_no_rebuild_lib {
         "#)
         .file("bar/src/lib.rs", "pub fn bar() {}");
     p.build();
-    assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
+    assert_that(p.process(cargo_dir().join("cargo")).arg("build")
+                 .env("FOO", Some("bar")),
                 execs().with_status(0)
                        .with_stdout(format!("{} foo v0.5.0 ({})\n",
                                             COMPILING, p.url())));
-    p.root().move_into_the_past().assert();
-
-    // Now that we've built the library, it *should not* be built again as part
-    // of `cargo test`, even if we have some dev dependencies that weren't
-    // previously built.
-    File::create(&p.root().join("src/lib.rs")).write_str(r#"
-        #[cfg(test)] extern crate bar;
-        #[cfg(not(test))] fn foo() { bar(); }
-    "#).unwrap();
-    p.root().join("src/lib.rs").move_into_the_past().assert();
 
     assert_that(p.process(cargo_dir().join("cargo")).arg("test"),
                 execs().with_status(0)
index 1f06e35d0ba6f6c7088e72921795b11fec35dc74..cc5745b0dca48733634449395a1dcd0d4044f44f 100644 (file)
@@ -1,7 +1,6 @@
 // Currently the only cross compilers available via nightlies are on linux/osx,
 // so we can only run these tests on those platforms
-#![cfg(target_os = "linux")]
-#![cfg(target_os = "macos")]
+#![cfg(any(target_os = "linux", target_os = "macos"))]
 
 use std::os;
 use std::path;
index 0d164c8b817295433b81ef77b747d05e43f62c85..e739f3463aa1845a204a90d06f3c0b70d7d1d55e 100644 (file)
@@ -983,3 +983,45 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured\n
 ", compiling = COMPILING, running = RUNNING,
    dir = p.url()).as_slice()));
 })
+
+test!(almost_cyclic_but_not_quite {
+    let p = project("a")
+        .file("Cargo.toml", r#"
+            [package]
+            name = "a"
+            version = "0.0.1"
+            authors = []
+
+            [dev-dependencies.b]
+            path = "b"
+            [dev-dependencies.c]
+            path = "c"
+        "#)
+        .file("src/lib.rs", r#"
+            #[cfg(test)] extern crate b;
+            #[cfg(test)] extern crate c;
+        "#)
+        .file("b/Cargo.toml", r#"
+            [package]
+            name = "b"
+            version = "0.0.1"
+            authors = []
+
+            [dependencies.a]
+            path = ".."
+        "#)
+        .file("b/src/lib.rs", r#"
+            extern crate a;
+        "#)
+        .file("c/Cargo.toml", r#"
+            [package]
+            name = "c"
+            version = "0.0.1"
+            authors = []
+        "#)
+        .file("c/src/lib.rs", "");
+
+    assert_that(p.cargo_process("build"), execs().with_status(0));
+    assert_that(p.process(cargo_dir().join("cargo")).arg("test"),
+                execs().with_status(0));
+})